package com.android.Bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.android.DBTools.ADUS;
import com.android.DBTools.DBConnection;
import com.android.ObjectBean.ContractObjectList;

import net.sf.json.JSONArray;

public class ContractBean {
	public String contractSelect() throws ClassNotFoundException, SQLException {
		String sql = "SELECT c.contractID,c.contractName,c.contractCon,c.contractDate,"
				+ "c.contractSDate,c.contractEDate FROM contract AS c";
		ResultSet rs=ADUS.selectData(sql);
		List<ContractObjectList> list =new ArrayList<ContractObjectList>();
		while(rs.next()){
			ContractObjectList contract=new ContractObjectList();
			contract.setContractID(rs.getString(rs.findColumn("contractID")));
			contract.setContractName(rs.getString(rs.findColumn("contractName")));
			contract.setContractCon(rs.getString(rs.findColumn("contractCon")));
			contract.setContractDate(rs.getString(rs.findColumn("contractDate")));
			contract.setContractSDate(rs.getString(rs.findColumn("contractSDate")));
			contract.setContractEDate(rs.getString(rs.findColumn("contractEDate")));
			list.add(contract);
		}
		DBConnection.closeCon();
		JSONArray json=JSONArray.fromObject(list);
		return json.toString();
	}
}
